/**
 * Copyright (c) 2010 Basil Shikin, BugStat Project
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.bugstat.common.bugs;

import java.util.Date;

/**
 * This class represents a bug that can be retrieved from bug tracking system and later processed to
 * generate graphs
 * 
 * @author Basil Shikin
 */
public class Bug
{
    private int id;

    private Date       createdAt;
    private User       createdBy;
    
    private User       assignedTo;
    private Status     status;
    private Resolution resolution;
    private Priority   priority;
    private Severity   severity;

    private Product    product;
    private Component  component;
    private Platform   platform;

    private short      commentNumber;

    /**
     * Get bug ID
     * 
     * @return the id of current bug
     */
    public int getId()
    {
        return id;
    }

    /**
     * Get date when bug was created
     * 
     * @return Date when bug was created
     */
    public Date getCreatedAt()
    {
        return new Date( createdAt.getTime() );
    }

    /**
     * Get user who created the bug
     * 
     * @return Bug tracking user who created the bug
     */
    public User getCreatedBy()
    {
        return createdBy;
    }
   
    /**
     * Get product for which the bug has been filed
     * 
     * @return Product bug product.
     */
    public Product getProduct()
    {
        return product;
    }
    
    /**
     * Get current bug assignee
     * 
     * @return Bug tracking user whom the bug is assigned now
     */
    public User getAssignedTo()
    {
        return assignedTo;
    }

    /**
     * Get current bug status
     * 
     * @return Current bug status.
     */
    public Status getStatus()
    {
        return status;
    }

    /**
     * Get current bug resolution
     * 
     * @return Bug resolution
     */
    public Resolution getResolution()
    {
        return resolution;
    }

    /**
     * Get current bug priority
     * 
     * @return Current priority
     */
    public Priority getPriority()
    {
        return priority;
    }

    /**
     * Get current bug severity
     * 
     * @return Current severity
     */
    public Severity getSeverity()
    {
        return severity;
    }

    /**
     * Get current component bug filed against
     * 
     * @return Current bug component
     */
    public Component getComponent()
    {
        return component;
    }

    /**
     * Get current bug platform
     * 
     * @return Current bug platform
     */
    public Platform getPlatform()
    {
        return platform;
    }

    /**
     * Get current number of comments to the bug
     * 
     * @return Number of bug comments
     */
    public short getCommentsNumber()
    {
        return commentNumber;
    }
    
    public boolean isOpen()
    {
        return status == Status.OPEN;
    }
    
    public boolean isEnhancement()
    {
        return severity == Severity.ENHANCEMENT;
    }
    
    public void setId(int id)
    {
        this.id = id;
    }

    public void setCreatedAt(Date createdAt)
    {
        this.createdAt = createdAt;
    }
    
    public void setAssignedTo(User assignedTo)
    {
        this.assignedTo = assignedTo;
    }

    public void setCreatedBy(User createdBy)
    {
        this.createdBy = createdBy;
    }
    
    public void setStatus(Status status)
    {
        this.status = status;
    }
    
    public void setResolution(Resolution resolution)
    {
        this.resolution = resolution;
    }
    
    public void setPriority(Priority priority)
    {
        this.priority = priority;
    }
    
    public void setSeverity(Severity severity)
    {
        this.severity = severity;
    }
    
    public void setComponent(Component component)
    {
        this.component = component;
    }
    
    public void setProduct(Product product)
    {
        this.product = product;
    }

    public void setPlatform(Platform platform)
    {
        this.platform = platform;
    }

    public void setCommentsNumber(short commentCount)
    {
        this.commentNumber = commentCount;
    }
}
